package com.masterrabbit.sn.util;

import lombok.Data;

@Data
public class R<T> {
    private int code;
    private String msg;
    private T data;

    private R(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static <T> R<T> ok(T data) {
        return new R<>(200, "成功", data);
    }

    public static <T> R<T> ok() {
        return new R<>(200, "成功", null);
    }

    public static <T> R<T> error(String msg) {
        return new R<>(500, msg, null);
    }
}
